package tk.winshu.transaction.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import tk.winshu.transaction.entity.User;

import java.util.List;

/**
 * @author Kevin
 * @since 2019/04/06.
 */
public interface IUserRepository extends JpaRepository<User, Integer> {

    @Query("select u from User u where u.code = ?1")
    User findByUnsureCode(String code);

    @Query("select u from User u where u.code in ?1")
    List<User> findAllByCode(List<String> codes);

    @Modifying
    @Query("delete from User u where u.code in ?1")
    void deleteByCodes(List<String> codes);
}
